import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		timeslot: {}, //时间选择
	},
	mutations: {
		redirect() {

		},
		timeslot(state, timeslot) {
			state.timeslot = timeslot
		},
		login(state, provider) {
			uni.setStorage({//缓存用户数据
			    key: 'userInfo',
			    data: provider.user
			}) 
			uni.setStorage({//缓存用户数据
			    key: 'userToken',
			    data: provider.token
			}) 
		},
		logout(state) {
			uni.removeStorage({  
                key: 'userInfo'  
            })
			uni.removeStorage({  
                key: 'userToken'  
            })
		},
		agreeTerms(state) {
			uni.setStorage({//是否同意条款
			    key: 'hasAgreeTerms',  
			    data: true  
			}) 
		}
	},
	actions: {
	
	}
})

export default store
